﻿using System;
using QDT.Common;
using QDT.Core.Assignments;
using QDT.Core.Members;

namespace QDT.Core.Deals
{
    /// <summary>
    /// 投资的交易信息类
    /// </summary>
    public class AssignmentOfLoan : Loan, IAggregeRoot
    {
        public AssignmentOfLoan()
        {
            CreateTime = DateTime.Now;
        }

        public AssignmentOfLoan(Assignment assignment, User user, decimal money)
            : this()
        {
            Check.Argument.IsNotNull(assignment, "assignment");
            Check.Argument.IsNotNull(user, "user");

            var proportion = money / assignment.BuyAmount;

            AssignmentId = assignment.ID;
            UserID = user.ID;
            UserName = user.UserName;
            Money = money;
            GetCreditor = proportion * assignment.Money;
            Bonus = proportion * assignment.TotalBonus;
            Advance = proportion * assignment.ThisProfit;
        }

        /// <summary>
        /// 所投债权的ID
        /// </summary>
        public int AssignmentId { get; private set; }

        /// <summary>
        /// 实际所得债权
        /// </summary>
        public decimal GetCreditor { get; set; }

        /// <summary>
        /// 奖励金额
        /// </summary>
        public decimal Bonus { get; set; }

        /// <summary>
        /// 垫付金额
        /// </summary>
        public decimal Advance { get; set; }

    }
}
